<template>
	<view class="container"><yxylInputs :inputs="inputs" @confirm="confirm" confirmText="领取"></yxylInputs></view>
</template>

<script>
import yxylInputs from '@/components/yxyl-inputs/yxyl-inputs.vue';
import { mapMutations } from 'vuex';
export default {
	components: { yxylInputs },
	data() {
		return {
			inputs: []
		};
	},
	onLoad() {
		// // #ifdef H5
		// this.$wechat.share({
		// 	link: this.$handlerAppMessagePath()
		// });
		// // #endif
	
		this.inputs.push({
			title: '学员姓名',
			key: 'preUserName',
			placeholder: '请输入学员姓名',
			required: true,
			type: 'text',
			errMsg: '请输入学员姓名',
			default:''
		});
		this.inputs.push({
			title: '电话号码',
			key: 'PreUserTelePhone',
			placeholder: '请输入电话号码',
			required: true,
			type: 'number',
			errMsg: '请输入电话号码',
			default:''
		});
	},
	onShareAppMessage(e) {
		return {
			path: this.$handlerAppMessagePath()
		};
	},
	methods: {
		...mapMutations('user', ['logout']),
		confirm(e) {
			this.$http
				.request({
					url: 'api/ChannelApi/ExChangeChannelPreUser',
					method: 'POST',
					data: e
				})
				.then(() => {
					this.logout();
					uni.showToast({
						icon: 'success',
						title: '兑换成功',
						success() {
							setTimeout(function() {
								uni.switchTab({
									url: '../index/index'
								});
							}, 1500);
						}
					});
				});
		}
	}
};
</script>

<style lang="scss" scoped></style>
